<?php

class AlipayCommand extends CConsoleCommand {

    public function actionNotify($aliid,$sn) {
        $userService = new UserService();
        $item = $userService->genTicketByAliidAndSn($aliid, $sn);
        if($item === false){
            //错误日志
//            echo "genTicketByAliidAndSn error";
            echo "1";
            return;
        }
        if($item !== true){
            if(false === B2cMsgRecords::model()->genPurchaseRecords($item)){
                //生成消息记录错误
    //            echo "genPurchaseRecords error";
                echo "2";
                return;
            }
        }
        echo "0";
        
    }
    
    public function actionTest()
    {
        $ret = exec("./yiic alipay notify --aliid=12345 --sn=20140117193845000006");
        echo $ret;
    }
}